home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / MPW_TOOL / TOOLS / TOOLS_WI / FLPATH.TXT next >
Text File  |  1990-05-12  |  2KB  |  92 lines

  1. {   An MPW Pascal Tool Demo - John Jeppson
  2.  
  3.     File Path and Directory Information:
  4.     what to save, how to extract it, and 
  5.     how to reconstruct it.
  6. }       
  7.     
  8.  
  9. PROGRAM test;
  10.  
  11. USES
  12.     Memtypes, Quickdraw, OSIntf, ToolIntf, PackIntf,
  13.     CursorCtl, Signal, PasLibIntf, IntEnv;
  14.  
  15. VAR
  16.  { Info to save - could be made into a record }
  17.     volumeName:  Str31;
  18.     fileName:    Str31;
  19.     directoryID: longint;
  20.  
  21.     reply:       SFReply;  { used by this demo }
  22.  
  23.  
  24. FUNCTION reconstructWD: integer;
  25.     VAR
  26.         pb:     WDPBRec;
  27.         err:    OSErr;
  28.         s:      string;
  29.     BEGIN
  30.         s := ':';
  31.         Insert(volumeName, s, 1);
  32.  
  33.         {get volume refnum}
  34.         pb.ioCompletion := NIL;
  35.         pb.ioNamePtr := @s;
  36.         pb.ioVRefNum := 0;
  37.         pb.ioWDProcID := 0;
  38.         pb.ioWDDirID := 0;
  39.         err := PBOpenWD(@pb, false);
  40.  
  41.         {get WDRefnum}
  42.         pb.ioCompletion := NIL;
  43.         pb.ioNamePtr := NIL;
  44.         {pb.ioVRefNum from above}
  45.         pb.ioWDProcID := 0;
  46.         pb.ioWDDirID := directoryID;
  47.         err := PBOpenWD(@pb, false);
  48.  
  49.         reconstructWD := pb.ioVRefNum;
  50.     END;
  51.  
  52. PROCEDURE extractFilePath;
  53.     VAR
  54.         pb:          WDPBRec;
  55.         err:         OSErr;
  56.     BEGIN
  57.         pb.ioCompletion := NIL;
  58.         pb.ioNamePtr := @volumeName;
  59.         pb.ioVRefNum := reply.vRefNum;
  60.         pb.ioWDIndex := 0;
  61.         pb.ioWDProcID := 0;
  62.         pb.ioWDVRefNum := 0;
  63.         err := PBGetWDInfo(@pb, false);
  64.         directoryID := pb.ioWDDirID;
  65.     END;
  66.  
  67. PROCEDURE getReply;
  68.     VAR
  69.         where:       Point;
  70.         typelist:    SFTypeList;
  71.     BEGIN
  72.         where.h := 75;
  73.         where.v := 75;
  74.         SFGetFile(where, '', NIL, - 1,
  75.                         typelist, NIL, reply);
  76.         IF reply.good THEN
  77.             fileName := reply.fName
  78.         ELSE
  79.             IEExit(2);
  80.     END;
  81.  
  82. BEGIN
  83.     InitGraf(@thePort);
  84.     SetFScaleDisable(true);
  85.  
  86.     getReply;
  87.     writeln(fileName, reply.vRefNum);
  88.     extractFilePath;
  89.     writeln(volumeName, directoryID);
  90.     writeln('restored WD = ', reconstructWD);
  91. END.
  92.